package com.example.springbooteventpublisher;

import java.time.LocalDateTime;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created on 2021-04-16
 */
@RestController
public class MessageProviderController {


    @Autowired
    private ApplicationEventPublisher eventPublisher;


    @GetMapping("/insert")
    public Object insertMessage(){


        Student student=new Student();
        student.setId(1);
        student.setName(LocalDateTime.now().toString());

        eventPublisher.publishEvent(new StudentEvent(this,student));

        return 1;



    }
}
